package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    public static final String TAG ="MainActivity";
    RadioButton Lshitou;
    RadioButton Ljiandao;
    RadioButton Lbu;
    RadioButton Rshitou;
    RadioButton Rjiandao;
    RadioButton Rbu;
    Button OK;
    TextView Resultn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.d(TAG, "onCreate");
        setContentView(R.layout.activity_main);
        Lshitou = (RadioButton) findViewById(R.id.Lshitou);
        Ljiandao = (RadioButton) findViewById(R.id.Ljiandao);
        Lbu = (RadioButton) findViewById(R.id.Lbu);
        Rshitou = (RadioButton) findViewById(R.id.Rshitou);
        Rjiandao = (RadioButton) findViewById(R.id.Rjiandao);
        Rbu = (RadioButton) findViewById(R.id.Rbu);
        OK = (Button) findViewById(R.id.ok);
        Resultn = (TextView) findViewById(R.id.resultn);
        OK.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (Lshitou.isChecked() && Rshitou.isChecked()) {
                    String str = "左石头 右石头 平局";
                    Resultn.setText(str);
                }
                if (Lshitou.isChecked() && Rbu.isChecked()) {
                    String str = "左石头 右布 右胜";
                    Resultn.setText(str);
                }
                if (Lshitou.isChecked() && Rjiandao.isChecked()) {
                    String str = "左石头 右剪刀 左胜";
                    Resultn.setText(str);
                } else if (Ljiandao.isChecked() && Rshitou.isChecked()) {
                    String str = "左剪刀 右石头 右胜";
                    Resultn.setText(str);
                } else if (Ljiandao.isChecked() && Rbu.isChecked()) {
                    String str = "左剪刀 右布 左胜";
                    Resultn.setText(str);
                } else if (Ljiandao.isChecked() && Rjiandao.isChecked()) {
                    String str = "左剪刀 右剪刀 平局";
                    Resultn.setText(str);
                } else if (Lbu.isChecked() && Rshitou.isChecked()) {
                    String str = "左布 右石头 左胜";
                    Resultn.setText(str);
                } else if (Lbu.isChecked() && Rbu.isChecked()) {
                    String str = "左布 右布 平局";
                    Resultn.setText(str);
                } else if (Lbu.isChecked() && Rjiandao.isChecked()) {
                    String str = "左布 右剪刀 右胜";
                    Resultn.setText(str);
                }
            }
        });
    }
        @Override
        protected void onStart()
        {
            super.onStart();
            Log.d(TAG,"onStart");
        }
        /*准备交互*/
        @Override
        protected void onResume()
        {
            super.onResume();
            Log.d(TAG,"onResume");
        }
        /*准备启动或恢复另一活动*/
        @Override
        protected void onPause()
        {
            super.onPause();
            Log.d(TAG,"onPause");
        }
        /*活动完全不可见时调用*/
        @Override
        protected void onStop()
        {
            super.onStop();
            Log.d(TAG,"onStop");
        }
        /*被销毁前调用*/
        @Override
        protected void onDestroy()
        {
            super.onDestroy();
            Log.d(TAG,"onDestroy");
        }
        /*停止状态变成运行状态*/
        @Override
        protected void onRestart()
        {
            super.onRestart();
            Log.d(TAG,"onRestart");
    }
}